package com.eboss2.sbs.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.eboss2.sbs.R;
import com.eboss2.sbs.model.CustomList;
import com.eboss2.sbs.model.ProfitInfo;
import com.mytools.tool.utils.StringUtils;

import java.util.List;

public class ProfitListAdapter extends BaseAdapter {

	private Context context;
	private List<ProfitInfo> datas;
	private LayoutInflater inflater;
	private ViewHolder holder = null;

	public ProfitListAdapter(Context context, List<ProfitInfo> datas) {
		this.context = context;
		this.datas = datas;
	}

	@Override
	public int getCount() {
		if(datas!=null&&datas.size()>0)return datas.size();
		else return 0;
	}

	@Override
	public ProfitInfo getItem(int position) {
		return datas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		
		inflater = LayoutInflater.from(context);

		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.listitem_mcht, null);
			holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
			holder.tv_grade = (TextView) convertView.findViewById(R.id.tv_grade);
//			holder.tv_from_to = (TextView) convertView.findViewById(R.id.tv_from_to);
			holder.tv_join_time = (TextView) convertView.findViewById(R.id.tv_join_time);

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		ProfitInfo data = datas.get(position);

		holder.tv_name.setText(data.getStatisDate()+"");
		holder.tv_grade.setText(data.getCount()+"人");
		holder.tv_join_time.setText(StringUtils.formatIntMoney(data.getProfitAmount())+"元");
		return convertView;
	}

	public final class ViewHolder {
		private TextView tv_name;
		private TextView tv_grade;
		private TextView tv_join_time;
	}

}
